package qq2564874169.tuaotuao.fx.app.so;


import qq2564874169.tuaotuao.fx.EventDispatcher;

import java.util.Map;

public interface ServiceContext extends AutoCloseable {
    EventDispatcher<ServiceObjectErrorArgs> evError();

    EventDispatcher<ServiceObjectArgs> evBefore();

    EventDispatcher<ServiceObjectArgs> evAfter();

    Map<String, Object> userdata();

    void use(ServiceObject serviceObject, Object state);

    @Override
    void close();

    default void use(ServiceObject serviceObject) {
        use(serviceObject, null);
    }

    default <T extends ServiceQo> T useQo(T qo) {
        use(qo);
        return qo;
    }

    default <T extends ServiceBo> T useBo(T bo) {
        use(bo);
        return bo;
    }
}
